package com.crm.pojo;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="t_deal")
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
public class Deal {
	private String id;
	private String dealName;
	private String desc;
	private String category;
	private String state;
	private String pic;
	private Contact contact;
	private User user;
	private String money;
	private String createTime;
	private String views;
	
	private Set<Dealnote> dealnoteSet;
	//private Set<Task> taskSet;
	private Set<Message> messageSet;
	
	@Id
	@GenericGenerator(name="pk",strategy="uuid")
	@GeneratedValue(generator="pk")
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getDealName() {
		return dealName;
	}
	public void setDealName(String dealName) {
		this.dealName = dealName;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}
	
	@ManyToOne
	@JoinColumn(name="contactId")
	public Contact getContact() {
		return contact;
	}
	public void setContact(Contact contact) {
		this.contact = contact;
	}
	
	@ManyToOne
	@JoinColumn(name="userId")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	public String getMoney() {
		return money;
	}
	public void setMoney(String money) {
		this.money = money;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getViews() {
		return views;
	}
	public void setViews(String views) {
		this.views = views;
	}
	
	@OneToMany(mappedBy="deal",cascade={CascadeType.REMOVE})
	public Set<Dealnote> getDealnoteSet() {
		return dealnoteSet;
	}
	public void setDealnoteSet(Set<Dealnote> dealnoteSet) {
		this.dealnoteSet = dealnoteSet;
	}
	
/*	@OneToMany(mappedBy="deal")
	public Set<Task> getTaskSet() {
		return taskSet;
	}
	public void setTaskSet(Set<Task> taskSet) {
		this.taskSet = taskSet;
	}*/
	
	
	@Transient
	public Set<Message> getMessageSet() {
		return messageSet;
	}
	public void setMessageSet(Set<Message> messageSet) {
		this.messageSet = messageSet;
	}
	
	
}
